package com.loocan.answer

import android.animation.AnimatorSet
import android.animation.ObjectAnimator
import android.content.Intent
import android.os.Bundle
import android.view.animation.AnticipateOvershootInterpolator
import androidx.appcompat.app.AppCompatActivity
import com.loocan.answer.databinding.ActivitySplashBinding
import com.leyou.sdk.ads.AdSdk
import com.leyou.sdk.ads.api.SplashAd
import com.leyou.sdk.ads.config.AdCode
import com.leyou.sdk.ads.interfaces.FusionAdNative
import com.loocan.answer.utils.CommonUtil
import com.loocan.answer.utils.SoundPlayer
import com.loocan.answer.utils.StatusBarUtils

/**
 * @author liupeng QQ:806875201
 * @time 2025/6/14 20:59
 * @Description  describe
 */

class SplashActivity : AppCompatActivity() {
    private lateinit var binding: ActivitySplashBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivitySplashBinding.inflate(layoutInflater)
        setContentView(binding.root)

        StatusBarUtils.setTopStatusTransparent(this)
        CommonUtil.hideNavKey(this)

        initAd()
    }

    private fun initAd() {
        val adCode = AdCode.Builder() //创建AdCode实例
            .setCodeId("31036098") //广告位ID
            .build()

        AdSdk.getAdManager().createAdNative(this)
            .loadSplashAd(adCode, object : FusionAdNative.SplashAdLoadListener {
                override fun onSplashAdLoad(splashAd: SplashAd) {
                    splashAd.setAdInteractionListener(object : SplashAd.AdInteractionListener {
                        override fun onAdShow() {
                            // 广告展示时回调该方法
                        }

                        override fun onAdExposure() {
                        }

                        override fun onAdClose() {
                            // 广告关闭时回调该方法
                            getNext()
                        }

                        override fun onAdClicked() {
                            // 广告被点击时回调该方法
                        }
                    })
                    splashAd.showAd(binding.rootLayout)
                }

                override fun onError(code: Int, msg: String?) {
                    // 广告出错
                    getNext()
                }
            })
    }

    private fun getNext(){
        startActivity(Intent(this, FirstActivity::class.java))
        finish()
    }
}